package com.ylr.mqtest;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

/**
 * @author ylr
 * @version 1.0.0
 * @ClassName RabbitMqConfig.java
 * @Description TODO
 * @createTime 2022年03月18日 18:03:00
 */
@SpringBootConfiguration
public class RabbitMqConfig {
    public static final String EVENT_QUEUE = "mqtestq";
    public static final String EVENT_EXCHANGE = "mqtestq";

    public RabbitMqConfig() {
    }

    @Bean({"EVENT_QUEUE"})
    public Queue eventQueue() {
        return new Queue("mqtestq");
    }

    @Bean({"EVENT_EXCHANGE"})
    TopicExchange eventExchange() {
        return new TopicExchange("mqtestq");
    }

    @Bean
    Binding bindingEventExchange(@Qualifier("EVENT_QUEUE") Queue eventQueue, @Qualifier("EVENT_EXCHANGE") TopicExchange topicExchange) {
        return BindingBuilder.bind(eventQueue).to(topicExchange).with("mqtest");
    }
}